package sk.hackcraft.util.generator;

import java.util.Random;

public class ExponentialRandom implements ContinuousRandom
{
	private final double lambda;
	private final Random random;
	
	public ExponentialRandom(long seed, double lambda)
	{
		this.random = new Random(seed);
		this.lambda = lambda;
	}
	
	public ExponentialRandom(double lambda)
	{
		this(SeedGenerator.getNextSeed(), lambda);
	}
	
	@Override
	public double next()
	{
		return -1/lambda * Math.log(random.nextDouble());
	}
}
